A stream channel is a type of channel which corresponds to a reliable byte stream. Stream channels extend the standard NIO readable and writable channel interfaces, meaning that many NIO classes and operations can act on them directly (and vice-versa). A stream channel which can only be read is referred to as a stream source channel. A stream channel which can only be written is referred to as a stream sink channel. A stream channel which can be both read and written is simply referred to as a "stream channel" and can behave as both a stream source and stream sink.
Stream channels can be differentiated from message channels by the fact that there are no message boundaries; for example, separate writes of 30 and 20 bytes to a stream may correspond to reads of 10, 15, and 25 bytes on the remote side of the stream. For this reason, accessing a stream source channel to read from two threads concurrently may cause undefined behavior or even cause an exception to be thrown; likewise for writes on stream sink channels. Full-duplex stream channels may always be read and written from different threads at the same time.
In addition to supporting the standard simple and scatter/gather read() and write() methods, stream channels support efficient zero- or low-copy transfer methods which allow transferring data from and to other stream source and sink channels, as well as transferring data from and to file channels. On some platforms, using these methods can greatly improve throughput by moving pages directly from one device driver to the other without actually copying any data into user space. On platforms which do not support such optimizations, these methods merely provide optimal implementations of these common tasks. For more information on zero-copy transfers, see Zero-Copy Transfers and Channel Utilities.